Skip to content

Increase test coverage for cmd - #162044

Open
Bolotnyj wants to merge 2 commits into
python:mainfrom
Bolotnyj:feature/cmd-coverage
Open

Bolotnyj wants to merge 2 commits into
python:mainfrom
Bolotnyj:feature/cmd-coverage

Conversation

@Bolotnyj

@Bolotnyj Bolotnyj commented Nov 15, 2026 •

Copy link
Copy Markdown

This PR adds unit tests for the cmd module in Lib/test/test_cmd.py, increasing test coverage from 75% to 100%.

Summary of added tests

  • parseline: handling commands starting with !.
  • completedefault: verifying the default empty list return value.
  • cmdloop: configuring completekey with readline and editline backends, handling missing readline, printing intro, and reading via builtins.input (including EOFError).
  • onecmd: dispatching unrecognized commands to default().
  • complete: testing completion states (0, 1, and non-matching buffers).
  • do_help: handling empty docstrings (cleandoc) and filtering duplicate command names.
  • print_topics: handling an empty ruler.
  • columnize: formatting an empty list (<empty>) and raising TypeError for non-string items.

Also sorted the top-level imports alphabetically according to PEP 8.

@bedevere-app bedevere-app Bot added the tests Tests in the Lib/test dir label Nov 15, 2026
@bedevere-app

bedevere-app Bot commented Nov 15, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@bedevere-app

bedevere-app Bot commented Nov 15, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@StanFromIreland

Copy link
Copy Markdown
Member

Did you check coverage? Do you have a before and after?

@Bolotnyj

Copy link
Copy Markdown
Author

@StanFromIreland, Yes, it was 75% before; now it’s 100%.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants